﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
using Dapper;
using Core;
using System.Threading;
using System.Net;

namespace DAL
{
    public class ReResourceEvaluateRecordDAL : SyncBase<Model.ReResourceEvaluateRecord>
    {
        static ReResourceEvaluateRecordDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReResourceEvaluateRecordDAL.addSQL = @"insert into ReResourceEvaluateRecord(ResourceID,FatherResource,ResourceName,ReTypeCode,StudentID,evaluateContent,UseGrade,UseClass,LessonID,EvaluateTime,EvaluateType,Evaluatepiont,RecordTime)
                                                                            values (@ResourceID,@FatherResource,@ResourceName,@ReTypeCode,@StudentID,@evaluateContent,@UseGrade,@UseClass,@LessonID,@EvaluateTime,@EvaluateType,@Evaluatepiont,@RecordTime);";
            ReResourceEvaluateRecordDAL.tbName = "ReResourceEvaluateRecord";
            ReResourceEvaluateRecordDAL.remoteUrl = "/Ayyfford/AddResourceEvaluateRecord";
            ReResourceEvaluateRecordDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12}),",
t.ResourceID, t.FatherResource.NullNumber(), t.ResourceName.NullString(), t.ReTypeCode.NullString(), t.StudentID.NullNumber(), t.evaluateContent.NullNumber(), t.UseGrade.NullString(), t.UseClass.NullNumber(), t.LessonID.NullNumber(), t.EvaluateTime.NullDate(), t.EvaluateType, t.Evaluatepiont.NullNumber(), t.RecordTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReResourceEvaluateRecord t)
        {
            SyncBase<Model.ReResourceEvaluateRecord>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReResourceEvaluateRecord>.AsyncData();
        }
    }
}
